revealer: Fix child size allocation at small scales
authorAlexander Larsson <alexl@redhat.com>
Tue, 11 Feb 2020 11:22:34 +0000 (12:22 +0100)
committerAlexander Larsson <alexl@redhat.com>
Tue, 11 Feb 2020 12:52:12 +0000 (13:52 +0100)
commitdc6fe091b9cffb6eb36a563982bf0899c7cbc981
treed16f26e8e581262ad9304dc2e71bb36f17980e80
parentaf98c46d04d86e192349d20711d36dbb1de9bc9d
revealer: Fix child size allocation at small scales

As pointed out in https://gitlab.gnome.org/GNOME/gtk/issues/1481
and seen from critical warnings with swinging revealers in widget-factory
there are some size allocation issues in GtkRevealer.

What happens is that we request a size of the revealer itself
based on the child natural size and the current stage of the transition
by applying a scale to the natural size. We then round up to nearest
int size. However, we want the widget to render as if it did get the
natural size so we can transform it, rather than the scaled down size.
For example, a label should not start ellipsizing in the animation.
So we inverse the scale when allocating the child.

Unfortunately, for very small scales the inversion of the scale can
result in very large sizes, and for such scales we rounded up the
requested size to 1, so we will be allocating huuuuge children.

In order to avoid such issue we pick an arbitrary maximum upscale
scale factor of 100. This means that in the case where the allocated
size is 1 we never allocate the child at > 100 px. This means
that in large downscaling cases we may run into the clipping issue
described above. However, at these downscaling levels (100 times!)
we're unlikely to notice much detail anyway.
gtk/gtkrevealer.c